<template>
	<view class="ikz-ad" v-if="ad_info.length">
		<view class="ikz-ad-box" :style="'margin-top:'+css_info.margin_top+'rpx;'">
			<view class="ikz-ad-title">
				广告招商
			</view>
			<view class="ikz-ad-list">
				<view class="ikz-ad-list-box" v-for="(item,index) in ad_info" :key="index" @click="getJump(item)">
					<image class="ikz-ad-img" :src="item.image"></image>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	var app = getApp();
	import ikz from "@/pages/Common/tools"
	export default {
		name: 'ad',
		props: {
			showData: {
				type: Object,
			},
			cssData: {
				type: Object,
			}
		},
		data() {
			return {
				css_info: {
					margin_top: 30,
				},
				ad_info: [],
			};
		},
		watch: {
			showData: {
				handler(newName, oldName) {
					this.adInfo();
				},
				immediate: true,
				deep: true
			},
			cssData: {
				handler(newName, oldName) {
					this.css_info = {
						margin_top: newName.margin_top || 25,
					}
				},
				immediate: true,
				deep: true
			}
		},
		mounted() {

		},
		methods: {
			adInfo() {
				console.log()
				this.ad_info = JSON.parse(JSON.stringify(this.showData));
				// var that = this;
				// var path = "/Supply/Wechat/Banner/listInfo";
				// var data = {
				// 	ban_page:this.ban_page,
				// };
				// ikz.get(path, data, (res) => {
				// 	if (res.data.status == 'success') {
				// 		this.banner_info = res.data.info;
				// 	} else {
				// 		uni.showModal({
				// 			title: '提示',
				// 			content: '服务器繁忙，请稍后再试',
				// 			showCancel: false,
				// 			success: function(res) {

				// 			}
				// 		});
				// 	}
				// })
			},
			getJump(e) {
				if(!uni.getStorageSync('local_user_session')) {
					uni.navigateTo({
						url: "/pages/login/index"
					})
					return
				}
				ikz.getNav(e.url)
				console.log(e.url)
			},
			// goBannerDetail(e){
			// 	var index = e.currentTarget.dataset.index;
			// 	var banner_info = this.banner_info;
			// 	//判断跳转到那个页面2入驻，3发布
			// 	if(banner_info[index].ban_type == 2){
			// 		uni.navigateTo({
			// 			url:'/pages/Component/Module/Demand/Program/Firm/Exhibition/index?id='+banner_info[index].ban_link_id
			// 		})
			// 	}else{
			// 		uni.navigateTo({
			// 			url:'/pages/Component/Module/Demand/Program/Demand/detail?id='+banner_info[index].ban_link_id
			// 		})
			// 	}
			// },
			change: function(e) {
				this.current = e.detail.current;
			},

		}
	};
</script>

<style>
	.ikz-ad {
		width: 95%;
		margin: 0 auto;
	}

	.ikz-ad-title {
		font-weight: 800;
	}

	.ikz-ad-list {
		margin-top: 30rpx;
		white-space: nowrap;
		overflow-x: auto;
	}

	.ikz-ad-list-box {
		display: inline-block;
	}

	.ikz-ad-img {
		width: 350rpx;
		height: 200rpx;
		margin-right: 20rpx;
		border-radius: 15rpx;
	}
</style>
